/*
 * Copyright (C) 2012 Nicolas BARBOTIN
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef GCUTILS_H
#define GCUTILS_H

#include <QtGui>
#include "GCDataReader.h"
#include "GCProject.h"

class GCProcess : public QDialog {
    Q_OBJECT

public:
    GCProcess(QString exe, QString path, QString b, QWidget *p = 0);

private:
    QVBoxLayout *vbl;
    QTextEdit *log;
    QPushButton *closeBtn;
    QProcess *make;
    QString bin;
    QString out;
    bool compOk;
    void copy(QString in, QString out);

private slots:
    void incomming();
    void canClose(int ec);
    void end();

signals:
    void ended();
};

class GCUtils : public QObject
{
    Q_OBJECT

public:
    static int OpenEventSelectDialog(GCDataReader *dr);
    static QIcon getIconByCat(int cat, GCDataReader *dr);
    static QIcon getIconByACat(int cat, GCDataReader *dr);
    static int OpenActionSelectDialog(GCDataReader *dr);
    static void OpenParamSelectDialog(GCProject *p, bool isAction, int cat, GCDataReader *dr, int oid, int eid, int aid = -1);
    static void SetDatas(GCProject *p, bool isAction, QVariant v, int cat, int oid, int eid, int aid = -1);
};

#endif // GCUTILS_H
